package abq2.jic.jic.plugin.operate.job;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;

import java.text.SimpleDateFormat;
import java.util.EventObject;

/**
 * 动态表单插件
 * 招聘信息弹窗插件，用于查看具体的招聘信息
 */
public class JobWindows extends AbstractFormPlugin implements Plugin {
    @Override
    public void afterCreateNewData(EventObject e) {
        super.afterCreateNewData(e);
        Object primaryKey = this.getView().getFormShowParameter().getCustomParam("jobId");
        if (primaryKey != null) {
            QFilter idFilter = new QFilter("id", QCP.equals,primaryKey); //过滤器
            DynamicObject job = BusinessDataServiceHelper.loadSingle("abq2_recruit", //加载招聘信息的单据信息
                            "id," + //内码
                            "abq2_title," + //标题
                            "abq2_company_name," + //公司名称
                            "abq2_address," + //地址
                            "abq2_exp," + //经验限制
                            "abq2_education," + //学历限制
                            "abq2_recruit_begin," + //招聘开始时间
                            "abq2_recruit_end," + //招聘截至时间
                            "abq2_job_name," + //职位名称
                            "abq2_phone," + //联系电话
                            "abq2_introduction," + //工作介绍
                            "abq2_job_requirements," + //工作要求
                            "abq2_salary," + //薪资待遇
                            "abq2_person_requirements," + //人员要求
                            "abq2_notice",  //注意事项
                    new QFilter[]{idFilter});
            this.getModel().setValue("abq2_textfield1",job.getString("abq2_title"));//标题
            this.getModel().setValue("abq2_textfield",job.getString("abq2_company_name"));//公司名称
            this.getModel().setValue("abq2_textfield2",job.getString("abq2_job_name"));//职位名称
            this.getModel().setValue("abq2_textfield3",job.getString("abq2_address.name"));//公司地址
            this.getModel().setValue("abq2_textfield4",job.getString("abq2_phone"));//联系电话
            this.getModel().setValue("abq2_textfield6",job.getString("abq2_exp"));//经验限制
            this.getModel().setValue("abq2_textfield5",job.getString("abq2_education"));//学历限制
            this.getModel().setValue("abq2_datefield", new SimpleDateFormat("yyyy-MM-dd").format(job.getDate("abq2_recruit_begin")));//招聘开始时间
            this.getModel().setValue("abq2_datefield1", new SimpleDateFormat("yyyy-MM-dd").format(job.getDate("abq2_recruit_end")));//招聘结束时间
            this.getModel().setValue("abq2_textfield7",job.getString("abq2_introduction"));//工作介绍
            this.getModel().setValue("abq2_textfield8",job.getString("abq2_job_requirements"));//工作要求
            this.getModel().setValue("abq2_textfield9",job.getString("abq2_salary"));//薪资待遇
            this.getModel().setValue("abq2_textfield10",job.getString("abq2_person_requirements"));//人员要求
            this.getModel().setValue("abq2_textfield11",job.getString("abq2_notice"));//注意事项
        }
    }
}